import {Component, ElementRef, OnInit} from '@angular/core';
import {UIRiskCheckPlanItem} from "../../../entity/UIRiskCheckPlanItem";
import {ActivatedRoute, Router} from "@angular/router";
import {DialogService} from "../../../service/dialogService";
import {CCRiskControllerService} from "../../../service/CCRiskController";

@Component({
  selector: 'app-risk-check-execution',
  templateUrl: './risk-check-execution.component.html',
  styleUrls: ['./risk-check-execution.component.css']
})
export class RiskCheckExecutionComponent implements OnInit {

  valuesForRiskExecutionList: UIRiskCheckPlanItem[] = [];
  riskCheckPlanItemId: number;
  riskCheckItem: UIRiskCheckPlanItem = new UIRiskCheckPlanItem();

  constructor(protected a_router: Router, public element: ElementRef,
              public route: ActivatedRoute, public _dialogService: DialogService, public riskService: CCRiskControllerService) {
    this.route.params.subscribe(params => {
      this.riskCheckPlanItemId = +params['id'];
    });
  }

  ngOnInit() {
    this.setup();
  }

  setup(): void{
    console.log('*** RiskCheckExecutionComponent ***');
    this.riskService.getRiskCheckItemDetail(this.riskCheckPlanItemId).subscribe(
      (res) => {
        this.riskCheckItem = res;
      }
    )
  }

  detail(v: any){
    this.a_router.navigate(['/dashboard/plan/execution', v.id, 'detail']);
  }

}
